{include file="common/head"/}
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>
    {include file="common/left"}
    <div class="main-content">
        <div class="main-content-inner">
            {include file="common/header_nav"}
            <div class="page-content">
                <div class="row maintop">
                    <div class="col-xs-12 col-sm-2">
                        <a href="{:url('add',array('catid'=>input('catid')))}">
                            <button class="btn btn-xs btn-danger">
                                <i class="ace-icon fa fa-plus bigger-110"></i>
                                添加内容
                            </button>
                        </a>
                    </div>
                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('index')}">
                        <input type="hidden" name="catid" value="{:input('catid')}">
                        <div class="col-xs-12 col-sm-6 btn-sespan">
                            <div class="input-group">
                                <span class="input-group-addon">
                                    <i class="ace-icon fa fa-search"></i>
                                </span>
                                <input type="text" name="val" id="val" class="form-control search-query admin_sea" value="{$keyword}" placeholder="输入用户名或者邮箱"/>
                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-xs btm-input btn-purple">
                                        搜索
                                    </button>
                                </span>
                            </div>
                        </div>
                        <div class="input-group-btn">
                            <a href="{:url('index')}">
                                <button type="button" class="btn btn-xs all-btn btn-purple">
                                    <span class="ace-icon fa fa-refresh icon-on-right bigger-110"></span>
                                    显示全部
                                </button>
                            </a>
                        </div>
                    </form>
                </div>
                <div class="row">
                    <div class="col-xs-12">

                        <div class="row">
                            <div class="col-xs-12">
                                <form action="{:url(listorder)}" method="post" name="listorder" id="listorder">
                                    <input type="hidden" name="catid" value="{:input('catid')}">
                                <div class="table-responsive">
                                    <table id="simple-table" class="table table-striped table-bordered table-hover center">
                                        <thead>
                                        <tr>
                                            <th class="center wh30">
                                                <label class="pos-rel">
                                                    <input type="checkbox" class="ace" id='chkAll' onclick='CheckAll(this.form)' value="全选"/>
                                                    <span class="lbl"></span>
                                                </label>
                                            </th>
                                            <th class="center wh60">排序</th>
                                            <th class="center wh40">ID</th>
                                            <th class="center">标题</th>
                                            {if condition="$fields['hits']"}<th class="center">点击</th>{/if}
                                            {if condition="$fields['username']"} <th width="60">用户名</th> {/if}
                                            <th class="center">发布时间</th>
                                            <th class="center" style="border-right:#CCC solid 1px;">操作</th>
                                        </tr>
                                        </thead>

                                        <tbody>
                                        {volist name="list" id="vo" key="k" empty="<tr><td colspan='7'>暂时没有数据</td></tr>"}
                                        <tr>
                                            <td>
                                                <label class="pos-rel">
                                                    <input name="ids" id="navid" class="ace" type='checkbox' value="{$vo['id']}">
                                                    <span class="lbl"></span>
                                                </label>
                                            </td>
                                            <td><input name='listorders[{$vo.id}]' type='text' size='3' value='{$vo.listorder}' class='input-text-c'></td>
                                            <td>{$vo['id']}</td>
                                            <td class="text-left">
                                                {if condition="$vo['catid']"}[<font color="green">{$categorys[$vo['catid']]['catname']}</font>]{/if}
                                                <font {if condition="$vo['title_style']!=''"}style ="{$vo['title_style']}"{/if}>{$vo['title']}</font>
                                            {if condition="$vo['thumb']!=''"}<img src="__STATIC__/img/admin_image.gif">{/if}
                                            {if condition="$vo['posid']!=0"}<img src="__STATIC__/img/admin_elite.gif">{/if}</td>
                                            {if condition="$fields['hits']"} <td>{$vo['hits']}</td>{/if}
                                            {if condition="$fields['username']"}<td>{$vo['username']}</td> {/if}

                                            <td>{$vo['createtime']|date="Y-m-d H:i:s",###}</td>
                                            <td>
                                                <div class="action-buttons">
                                                    <a class="green" href="{:url('edit',['id'=>$vo['id']])}" title="修改">
                                                        <i class="ace-icon fa fa-pencil bigger-130"></i> </a>
                                                    <a class="red" href="javascript:;" onclick="return del({$vo.id});" title="删除">
                                                        <i class="ace-icon fa fa-trash-o bigger-130"></i> </a>
                                                </div>
                                            </td>
                                        </tr>
                                        {/volist}
                                        <tr>
                                            <td colspan="8" align="left">
                                                <div class="pull-left">
                                                    <button type="button" class="btn btn-white btn-yellow btn-sm"  onclick="return delall();">删除</button>
                                                    <button type="submit" class="btn btn-white btn-yellow btn-sm">排序</button>
                                                </div>
                                                <div class="page pull-right">
                                                    {$page}
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div>
                                    </div>
                                </form>
                            </div><!-- /.span -->
                        </div><!-- /.row -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    {include file="common/foot" /}

</div><!-- /.main-container -->

<!-- inline scripts related to this page -->
<script type="text/javascript">
    function del(id) {
        layer.confirm('你确定要删除吗？', {icon: 3}, function (index) {
            layer.close(index);
            window.location.href = "{:url('listDel')}?id=" + id+'&catid='+"{:input('catid')}";
        });
    }
    function CheckAll(form) {
        for (var i = 0; i < form.elements.length; i++) {
            var e = form.elements[i];
            if (e.Name != 'chkAll' && e.disabled == false)
                e.checked = form.chkAll.checked;
        }
    }
    $(function(){
        $('#listorder').ajaxForm({
            beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
            success: complete, // 这是提交后的方法
            dataType: 'json'
        });

        function checkForm(){
        }
        function complete(data){
            if(data.status==1){
                layer.alert(data.info, {icon: 6}, function(index){
                    layer.close(index);
                    window.location.href=data.url;
                });
            }else{
                layer.alert(data.info, {icon: 5}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

    });
    function delall() {
        var ids = '';
        $("input[name=ids]:checked").each(function () {
            ids += $(this).val() + ',';
        });
        layer.confirm('确认要删除选中信息吗？', {icon: 3}, function(index){
            var catid = "{:input('catid')}";
            $.post("{:url('delall')}", {ids:ids,catid:catid}, function (result) {
                layer.msg(result.msg,{icon:5});
                window.location.href = result.url;
                return false;
            });
            layer.close(index);
        })

    }
</script>
</body>
</html>
